
/// all the analyses in the MS and online appendix for STUDY  (UK) 
/// by Muradova and Beauvais 2025///
/// stata 18.5

clear
set more on
use "Study_2_US_data_PLOSONE.dta"

/// MANIPULATION CHECK //: we check whether the treatment worked, by using the variable mc
by treatment, sort : summarize mc
ttesti 428 3.598131 1.15829 458 3.89083 1.134829   //comparing the placebo game vs. treatment game


/// EMPATHIC CONCERN // : we check whether playing the climate game led to increased empathic concern. we had several items to capture empathy, so we create an index measure for it and then rescale it to 0-1 for an ease in interpretation. 
factor sympathy empathy concern compassion moved
alpha sympathy empathy concern compassion moved
gen empathy_index=(sympathy+empathy+concern+compassion+moved)
tab empathy_index

sum empathy_index, meanonly
gen empathy_index_res = ( empathy_index - r(min) ) / ( r(max)-r(min) )
tab empathy_index_res
reg empathy_index_res i.treatment


// since ttest test in stata needs a binary treatment variable, i have to create several comparision treatment variables. 
// so the treatment=1 placebo game, =2 placebo with no information and =3 climate game
// first we create a variable to capture comparision between placebo game and treatment game

/// treatment, 1=placebo game, 2= placebo no climate information; 3=climate game
gen placebo_treatment=.
replace placebo_treatment=1 if treatment==1
replace placebo_treatment=2 if treatment==3

// 1- noinformation placebo 2- information placebo
gen placebo_pnoinfo=.
replace placebo_pnoinfo=2 if treatment==1
replace placebo_pnoinfo=1 if treatment==2

ttest empathy_index_res, by(placebo_treatment)
ttest empathy_index_res, by(placebo_pnoinfo)

/// no difference in all variables, so we pool the placebo and placebo no inofrmation conditions

gen btreatment=.
replace btreatment=1 if treatment==1
replace btreatment=1 if treatment==2
replace btreatment=2 if treatment==3
fre treatment
fre btreatment

lab var btreatment "dichotomous treatment variable"

///

sum empathy_index if btreatment==1
gen empathy_standardized = (empathy_index - 13.91707) / 5.766545
mean empathy_standardized

reg empathy_standardized i.btreatment


/// ALL ELICITED EMOTIONS //: we rescale all these emotions for an ease in interpretation.

foreach v of var fear-helplessness {
    su `v', meanonly
    gen `v'_s = (`v' - r(min)) / (r(max) - r(min))
    label var `v'_s "`: var label `v'', scaled"
}


//testing whether treatment elicits emotions
ttest fear_s, by(btreatment)
ttest anger_s, by(btreatment)
ttest sadness_s,by(btreatment)
ttest happiness_s, by(btreatment)
ttest guilt_s,by(btreatment)
ttest helplessness_s,by(btreatment)

/// OUTCOME VARIABLES // : we run OLS regression analyses and report them in the table
/// world_climate natural_cause selfharm postfuture polp1 polp2 polp3 petition postdiscussion

ssc install estout

reg world_climate i.btreatment
estimates store model1

reg natural_cause i.btreatment
estimates store model2

reg selfharm i.btreatment
estimates store model3

reg postfuture i.btreatment
estimates store model4

reg polp1 i.btreatment
estimates store model5

reg polp2 i.btreatment
estimates store model6

reg polp3 i.btreatment
estimates store model7

reg postdiscussion i.btreatment
estimates store model8

reg petition i.btreatment
estimates store model9

esttab model1 model2 model3 model4 model5 model6 model7 model8 model9 using results2_table.csv, se star r2 replace

/// WITHIN-SUBJECT DISCUSSING CLIMATE CHANGE ///
fre prediscussion
fre postdiscussion
gen change = postdiscussion - prediscussion
ttest change, by(btreatment)

by btreatment, sort : ttest prediscussion == postdiscussion

/// CAUSAL MEDIATION ANALYSES ///
* creating an index for attitudes
factor world_climate natural_cause postfuture selfharm
gen attitudes=(world_climate+natural_cause+postfuture+selfharm)
tab attitudes

sum attitudes, meanonly
gen attitudes_s = ( attitudes - r(min) ) / ( r(max)-r(min) )
tab attitudes_s

* creating an index for polpreferences
factor polp1 polp2 polp3
gen polpreferences=(polp1+polp2+polp3)
tab polpreferences
///now rescaling it to 0-1
sum polpreferences, meanonly
gen polpreferences_s = (polpreferences - r(min) ) / ( r(max)-r(min) )
tab polpreferences_s

//search and install medeff
search medeff

// beliefs/attitudes
medeff (regress empathy_index_res btreatment) (regress attitudes btreatment empathy_index_res), mediate(empathy_index_res) treat(btreatment) sims(1000) seed(1) 

**** policy preferences
medeff (regress empathy_index_res btreatment) (regress polpreferences_s btreatment empathy_index_res), mediate(empathy_index_res) treat(btreatment) sims(1000) seed(1) 

**** petition 
medeff (regress empathy_index_res btreatment) (regress petition btreatment empathy_index_res), mediate(empathy_index_res) treat(btreatment) sims(1000) seed(1) 

**** discussion, also controlling for pre treatment discussion
sum prediscussion, meanonly
gen prediscussion_s = (prediscussion - r(min) ) / ( r(max)-r(min) )
tab prediscussion_s

sum postdiscussion, meanonly
gen postdiscussion_s = (postdiscussion - r(min) ) / ( r(max)-r(min) )
tab postdiscussion_s

medeff (regress empathy_index_res btreatment) (regress postdiscussion_s btreatment empathy_index_res prediscussion_s), mediate(empathy_index_res) treat(btreatment) sims(1000) seed(1) 


///ONLINE APPENDIX, descriptive tables
tabout gender education party region /// 
using tableus.xls, replace style(xls) ///
font(bold) oneway c(freq col cum) f(0c 1) ///
clab(Count Col_% Cum_%) ///
npos(col) nlab(Sample) 

// ONLINE APPENDIX, variable means and sd. the var's: world_climate natural_cause postfuture selfharm polp1 polp2 polp3 petition postdiscussion
estpost summarize world_climate natural_cause postfuture selfharm polp1 polp2 polp3 petition postdiscussion
esttab, cells("mean sd") label

// ONLINE APPENDIX, models with covariates

reg world_climate i.btreatment ideology_1 i.party age i.gender i.education i.race 
estimates store model1

reg natural_cause i.btreatment ideology_1 i.party age i.gender i.education i.race 
estimates store model2

reg selfharm i.btreatment ideology_1 i.party age i.gender i.education i.race 
estimates store model3

reg postfuture i.btreatment ideology_1 i.party age i.gender i.education i.race 
estimates store model4

reg polp1 i.btreatment ideology_1 i.party age i.gender i.education i.race 
estimates store model5

reg polp2 i.btreatment ideology_1 i.party age i.gender i.education i.race 
estimates store model6

reg polp3 i.btreatment ideology_1 i.party age i.gender i.education i.race 
estimates store model7

reg postdiscussion i.btreatment ideology_1 i.party age i.gender i.education i.race 
estimates store model8

reg petition i.btreatment ideology_1 i.party age i.gender i.education i.race 
estimates store model9

esttab model1 model2 model3 model4 model5 model6 model7 model8 model9 using results2_table.csv, se star r2 replace

////END///

